﻿Public Class Download
    Inherits System.Web.UI.Page
    Dim connStr As String = ConfigurationManager.ConnectionStrings("yafnet").ConnectionString
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub DownloadList1_ItemDataBound(ByVal sender As Object, ByVal e As RepeaterItemEventArgs)
       


    End Sub
    Public Function SetListImage(Image As String)
        Dim myimage As String = Server.MapPath("Images\" & Image)
        If System.IO.File.Exists(myimage) Then

            SetListImage = "Images/" & Image

        Else

            SetListImage = "Images/Dl.jpg"

        End If



    End Function
    Public Function GetUser(id As String) As String
        GetUser = ""
        Dim dcon As New SqlClient.SqlConnection
        Dim dquery As New SqlClient.SqlCommand

        dcon.ConnectionString = connStr
        dquery.Connection = dcon
        'Select Query here
        dquery.CommandText = "SELECT        Name FROM            yaf_User WHERE        (UserID = " & id & ")"
        dcon.Open()
        Dim reader As SqlClient.SqlDataReader = dquery.ExecuteReader
        While reader.Read
            GetUser = reader("Name").ToString

        End While
        If GetUser = "" Then

            GetUser = "Unknown"
        End If
        dcon.Close()

    End Function
    Protected Function FormatSize(Bytes) As String
        FormatSize = SetBytes(Bytes)
    End Function
    Public Function getdls(id As String) As String
        getdls = 0

        Dim dcon As New SqlClient.SqlConnection
        Dim dquery As New SqlClient.SqlCommand
        dcon.ConnectionString = connStr
        dquery.Connection = dcon
        'Select Query here
        dquery.CommandText = "SELECT        count(FileID) as dls FROM            Downloads WHERE        (FileID = " & id & ")"
        dcon.Open()
        Dim reader As SqlClient.SqlDataReader = dquery.ExecuteReader
        While reader.Read
            getdls = reader("dls").ToString

        End While
        If getdls = "" Then

            getdls = 0
        End If
        dcon.Close()

    End Function
End Class